<template>
  <van-cell
    class="article-item"
    :to="{ name: 'article', params: { articleId: articleInfo.art_id } }"
  >
    <span class="title van-multi-ellipsis--l3" slot="title">{{
      articleInfo.title
    }}</span>
    <template slot="default" v-if="articleInfo.cover.type === 1">
      <van-image
        width="116"
        height="73"
        v-for="(img, index) in articleInfo.cover.images"
        :key="'img' + index"
        :src="img + 1"
        fit="contain"
      />
    </template>
    <template slot="label">
      <div class="label-img" v-if="articleInfo.cover.type === 3">
        <van-image
          height="73"
          v-for="(img, index) in articleInfo.cover.images"
          :key="'img' + index"
          :src="img + 1"
          fit="contain"
        />
      </div>
      <div class="label-text">
        <span>{{ articleInfo.aut_name }}</span>
        <span>{{ articleInfo.comm_count }}评论</span>
        <span>{{ articleInfo.pubdate | formatTimeFromNow }}</span>
      </div>
    </template>
  </van-cell>
</template>

<script>
import { getTimeFromNow } from '@/utils/formatTime'
export default {
  props: {
    articleInfo: {
      trpe: Object,
      require: true
    }
  },
  filters: {
    formatTimeFromNow(val) {
      return getTimeFromNow(val)
    }
  }
}
</script>

<style lang="less" scoped>
.article-item {
  .title {
    font-size: 16px;
    color: #3a3a3a;
  }
  /deep/ .van-cell__value {
    flex: unset;
    margin-left: 15px;
  }
  .label-img {
    display: flex;
    .van-image {
      // 选择 不是最后一个元素
      &:not(:last-child) {
        margin-right: 4px;
      }
      flex: 1;
    }
  }
  .label-text {
    font-size: 11px;
    color: #b4b4b4;
    span {
      margin-right: 12px;
    }
  }
}
</style>
